﻿@model Zatify.WebUI.Models.BusinessProfileBusinessHoursViewModel
@{
    ViewBag.Title = "Profile - Hours";
    ViewBag.ContentTitle = "Profile - Hours";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@section Styles
{
 <style type="text/css">
 .inner_container
 {
     float: none;
 }
 </style>
}
@section Scripts
{
    <script type="text/javascript">

        $(document).ready(function () {

            $('.chk_day_closed').each(function (index, item) {

                if ($(item).attr('checked')) {

                    $('#' + $(item).data("day-code") + 'From').attr("disabled", "disabled");
                    $('#' + $(item).data("day-code") + 'To').attr("disabled", "disabled");
                    $("#" + $(item).data("day-code") + "24HoursOpen").attr("disabled", "disabled");
                    $("#" + $(item).data("day-code") + "From").val("00:00:00");
                    $("#" + $(item).data("day-code") + "To").val("00:00:00");
                }

            });

            $(".chk_24_open").each(function (index, item) {

                if ($(item).attr("checked")) {

                    $('#' + $(item).data("day-code") + 'From').attr("disabled", "disabled");
                    $('#' + $(item).data("day-code") + 'To').attr("disabled", "disabled");
                    $("#" + $(item).data("day-code") + "Closed").attr("disabled", "disabled");
                    $("#" + $(item).data("day-code") + "From").val("00:00:00");
                    $("#" + $(item).data("day-code") + "To").val("00:00:00");
                }
            });
        });

        function enableHours(dayOfWeek) {

            var isClosed = $("#" + dayOfWeek + "Closed").attr("checked");

            if (isClosed) {

                $("#" + dayOfWeek + "From").attr("disabled", "disabled");
                $("#" + dayOfWeek + "To").attr("disabled", "disabled");
                $("#" + dayOfWeek + "24HoursOpen").removeAttr("checked");
                $("#" + dayOfWeek + "24HoursOpen").attr("disabled", "disabled");
            }
            else {

                $("#" + dayOfWeek + "From").removeAttr("disabled");
                $("#" + dayOfWeek + "To").removeAttr("disabled");
                $("#" + dayOfWeek + "24HoursOpen").removeAttr("disabled");
            }
        }

        function open24(dayOfWeek) {

            var is24Opened = $("#" + dayOfWeek + "24HoursOpen").attr("checked");

            if (is24Opened) {

                $("#" + dayOfWeek + "From").attr("disabled", "disabled");
                $("#" + dayOfWeek + "To").attr("disabled", "disabled");
                $("#" + dayOfWeek + "Closed").removeAttr("checked");
                $("#" + dayOfWeek + "Closed").attr("disabled", "disabled");

                $("#" + dayOfWeek + "From").val("00:00:00");
                $("#" + dayOfWeek + "To").val("00:00:00");
            }
            else {

                $("#" + dayOfWeek + "From").removeAttr("disabled");
                $("#" + dayOfWeek + "To").removeAttr("disabled");
                $("#" + dayOfWeek + "Closed").removeAttr("disabled");
            }
        }
    
    </script>
}
<div class="business_interface_area">
    @using (Html.BeginForm())
    {
        <div class="business_profile_hours">
            <div class="business_hour_line">
                <label class="business_hour_label_day">
                    Mon</label>
                @Html.DropDownListFor(m => m.MonFrom, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label style="float: left;">
                    -</label>
                @Html.DropDownListFor(m => m.MonTo, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.MonClosed, new { @class = "business_hour_checkbox chk_day_closed", onclick = "enableHours('Mon')", data_day_code = "Mon" })
                    <span class="business_hour_checkbox_text">Closed</span>
                </label>
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.Mon24HoursOpen, new { @class = "business_hour_checkbox chk_24_open", onclick = "open24('Mon')", data_day_code = "Mon" })
                    <span class="business_hour_checkbox_text">24h</span>
                </label>
            </div>
            <div class="clearfix">
            </div>
            <div class="business_hour_line">
                <label class="business_hour_label_day">
                    Tue</label>
                @Html.DropDownListFor(m => m.TueFrom, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label style="float: left;">
                    -</label>
                @Html.DropDownListFor(m => m.TueTo, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.TueClosed, new { @class = "business_hour_checkbox chk_day_closed", onclick = "enableHours('Tue')", data_day_code = "Tue" })
                    <span class="business_hour_checkbox_text">Closed</span>
                </label>
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.Tue24HoursOpen, new { @class = "business_hour_checkbox chk_24_open", onclick = "open24('Tue')", data_day_code = "Tue" })
                    <span class="business_hour_checkbox_text">24h</span>
                </label>
            </div>
            <div class="clearfix">
            </div>
            <div class="business_hour_line">
                <label class="business_hour_label_day">
                    Wed</label>
                @Html.DropDownListFor(m => m.WedFrom, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label style="float: left;">
                    -</label>
                @Html.DropDownListFor(m => m.WedTo, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.WedClosed, new { @class = "business_hour_checkbox chk_day_closed", onclick = "enableHours('Wed')", data_day_code = "Wed" })
                    <span class="business_hour_checkbox_text">Closed</span>
                </label>
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.Wed24HoursOpen, new { @class = "business_hour_checkbox chk_24_open", onclick = "open24('Wed')", data_day_code = "Wed" })
                    <span class="business_hour_checkbox_text">24h</span>
                </label>
            </div>
            <div class="clearfix">
            </div>
            <div class="business_hour_line">
                <label class="business_hour_label_day">
                    Thu</label>
                @Html.DropDownListFor(m => m.ThuFrom, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label style="float: left;">
                    -</label>
                @Html.DropDownListFor(m => m.ThuTo, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.ThuClosed, new { @class = "business_hour_checkbox chk_day_closed", onclick = "enableHours('Thu')", data_day_code = "Thu" })
                    <span class="business_hour_checkbox_text">Closed</span>
                </label>
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.Thu24HoursOpen, new { @class = "business_hour_checkbox chk_24_open", onclick = "open24('Thu')", data_day_code = "Thu" })
                    <span class="business_hour_checkbox_text">24h</span>
                </label>
            </div>
            <div class="clearfix">
            </div>
            <div class="business_hour_line">
                <label class="business_hour_label_day">
                    Fri</label>
                @Html.DropDownListFor(m => m.FriFrom, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label style="float: left;">
                    -</label>
                @Html.DropDownListFor(m => m.FriTo, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.FriClosed, new { @class = "business_hour_checkbox chk_day_closed", onclick = "enableHours('Fri')", data_day_code = "Fri" })
                    <span class="business_hour_checkbox_text">Closed</span>
                </label>
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.Fri24HoursOpen, new { @class = "business_hour_checkbox chk_24_open", onclick = "open24('Fri')", data_day_code = "Fri" })
                    <span class="business_hour_checkbox_text">24h</span>
                </label>
            </div>
            <div class="clearfix">
            </div>
            <div class="business_hour_line">
                <label class="business_hour_label_day">
                    Sat</label>
                @Html.DropDownListFor(m => m.SatFrom, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label style="float: left;">
                    -</label>
                @Html.DropDownListFor(m => m.SatTo, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.SatClosed, new { @class = "business_hour_checkbox chk_day_closed", onclick = "enableHours('Sat')", data_day_code = "Sat" })
                    <span class="business_hour_checkbox_text">Closed</span>
                </label>
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.Sat24HoursOpen, new { @class = "business_hour_checkbox chk_24_open", onclick = "open24('Sat')", data_day_code = "Sat" })
                    <span class="business_hour_checkbox_text">24h</span>
                </label>
            </div>
            <div class="clearfix">
            </div>
            <div class="business_hour_line">
                <label class="business_hour_label_day">
                    Sun</label>
                @Html.DropDownListFor(m => m.SunFrom, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label style="float: left;">
                    -</label>
                @Html.DropDownListFor(m => m.SunTo, ((IEnumerable<SelectListItem>)ViewData["BusinessHours"]), new { @class = "business_hour_selectbox" })
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.SunClosed, new { @class = "business_hour_checkbox chk_day_closed", onclick = "enableHours('Sun')", data_day_code = "Sun" })
                    <span class="business_hour_checkbox_text">Closed</span>
                </label>
                <label class="business_hour_label_close">
                    @Html.CheckBoxFor(m => m.Sun24HoursOpen, new { @class = "business_hour_checkbox chk_24_open", onclick = "open24('Sun')", data_day_code = "Sun" })
                    <span class="business_hour_checkbox_text">24h</span>
                </label>
            </div>
            <div class="clearfix">
            </div>
            <input type="submit" value="Save" class="blue_btn" style="margin-left: 0px;" />
        </div>
        @Html.ValidationSummary()
    }
    <div class="clearfix">
    </div>
</div>
